ubuntu 15.10 下搭建 nginx php5 开发环境遇到问题

您所在的位置:网站首页 ubuntu安装error code-16 ubuntu 15.10 下搭建 nginx php5 开发环境遇到问题

ubuntu 15.10 下搭建 nginx php5 开发环境遇到问题

2023-03-15 15:18| 来源: 网络整理| 查看: 265

  第一次在 ubuntu 15.10 下搭建 nginx  php5 开发环境。没想到遇到各种问题。

      主要在于在 通过apt-get intsall php 和nginx的后,发现不同操作系统下的配置文件是不完全一致的,ubuntu上的被打散了,而且配置项也有差异。

    该系统下:

# Default server configuration server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /var/www/html; //这个写法有助于同时配置了apache和nginx的用户测试性能,因为站点根目录没有变,不需要再移动项目。当然,前提是apache的安装方式也是apt-get insall apache2 啦。 # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#下面这部分需要被放开注释,目的当然是为了nginx知道如何去解析php了;但是下面有2行只能选一个,否则#总是报冲突。

#nginx 日志文件出现"fastcgi_pass" directive is duplicate 错误

#错误日志查看方法: #cat /var/log/nginx/erro.log. 当然,还有tail cat等命令 location ~ \.php$ { include snippets/fastcgi-php.conf; # # With php5-cgi alone:    #这句不要放开啊,注释而已 # fastcgi_pass 127.0.0.1:9000;//二选一 # # With php5-fpm    #这句也不要放开啊,注释而已 fastcgi_pass unix:/var/run/php5-fpm.sock;//二选一 } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }

#还有需要注意的是,/etc/nginx/sites-enabled/default 文件是/etc/nginx/sites-available/default 文件的软连接#文件,所以,当报错的时候,也不要认为是这两个文件重复。

#查看是不是他的软链接其实很方便,只需要#ls -all 或者ll就会发现他的文件属性为 l(link) 开头,为软链接文#件,相当于win下的快捷方式。不懂得需要脑补linux基础知识。

但是,但是。。。。。

本人的windows下的phpstudy2016的niginx+php配置中的nginx.conf 文件如下,已经包含了server{}  节点,就是服务器容器默认的站点配置。对比之后可以发现,在上面的ubuntu中是对配置文件做了很大的拆分了。

看了下文的win下的配置文件感觉清晰多了,在一个文件中,不过这个可能是phpstudy对文件做了整合,win下我还没一个个安装过,是集成环境都是。

不过熟悉了以后只要找到最初始的主配文件,看里面的include,找下一个文件就行了。基本都是包含,然后成为一个完整的配置文件。

#  power by www.phpStudy.net  #user  nobody; worker_processes  1; #error_log  logs/error.log; #error_log  logs/error.log  notice; #error_log  logs/error.log  info; #pid        logs/nginx.pid; events {     worker_connections  1024; } http {     include       mime.types;     default_type  application/octet-stream;     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '     #                  '$status $body_bytes_sent "$http_referer" '     #                  '"$http_user_agent" "$http_x_forwarded_for"';     #access_log  logs/access.log  main;     sendfile        on;     #tcp_nopush     on;     #keepalive_timeout  0;     keepalive_timeout  65;     #tcp_nodelay on;   fastcgi_connect_timeout 300;   fastcgi_send_timeout 300;   fastcgi_read_timeout 300;   fastcgi_buffer_size 128k;   fastcgi_buffers 4 128k;   fastcgi_busy_buffers_size 256k;   fastcgi_temp_file_write_size 256k;   #gzip  on;   gzip on;   gzip_min_length  1k;   gzip_buffers     4 32k;   gzip_http_version 1.1;   gzip_comp_level 2;   gzip_types       text/plain application/x-javascript text/css application/xml;   gzip_vary on;   gzip_disable "MSIE [1-6].";   server_names_hash_bucket_size 128;   client_max_body_size     100m;    client_header_buffer_size 256k;   large_client_header_buffers 4 256k;     server {         listen       80;         server_name  www.ad.com;         #charset koi8-r;         #access_log  logs/host.access.log  main;         root   "D:/phpStudy/WWW/ad";         location / {             index  index.html index.htm index.php l.php;            autoindex  on;    if (!-e $request_filename) {                         rewrite ^(.*)$ /index.php/$1 last;                         break;                 }         }         #error_page  404              /404.html;         # redirect server error pages to the static page /50x.html         #         error_page   500 502 503 504  /50x.html;         location = /50x.html {             root   html;         }         # proxy the PHP scripts to Apache listening on 127.0.0.1:80         #         #location ~ \.php$ {         #    proxy_pass   http://127.0.0.1;         #}         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000         #         location ~ \.php(.*)$  {             fastcgi_pass   127.0.0.1:9000;             fastcgi_index  index.php;             fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;             fastcgi_param  PATH_INFO  $fastcgi_path_info;             fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;             include        fastcgi_params;         }         # deny access to .htaccess files, if Apache's document root         # concurs with nginx's one         #         #location ~ /\.ht {         #    deny  all;         #}     }     # another virtual host using mix of IP-, name-, and port-based configuration     #     #server {     #    listen       8000;     #    listen       somename:8080;     #    server_name  somename  alias  another.alias;     #    location / {     #        root   html;     #        index  index.html index.htm;     #    }     #}     # HTTPS server     #     #server {     #    listen       443;     #    server_name  localhost;     #    ssl                  on;     #    ssl_certificate      cert.pem;     #    ssl_certificate_key  cert.key;     #    ssl_session_timeout  5m;     #    ssl_protocols  SSLv2 SSLv3 TLSv1;     #    ssl_ciphers  HIGH:!aNULL:!MD5;     #    ssl_prefer_server_ciphers   on;     #    location / {     #        root   html;     #        index  index.html index.htm;     #    }     #} include vhosts.conf; }



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3